//
//  ReleaseViewController.m
//  shuiyun
//
//  Created by 马田成 on 2017/9/5.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "ReleaseViewController.h"

#import "ReleseCollectionViewCell.h"

#import "ReleaseRecordViewController.h"
#import "ReleaseDealViewController.h"
#import "ReleaseGoodsViewController.h"
#import "ReleaseDirectoryViewController.h"
#import "ReleaseComplaintViewController.h"
#import "RealseApplyWorkViewController.h"


@interface ReleaseViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
{
    
    UICollectionView *downcollectionView;
    
    
    
}
@end

@implementation ReleaseViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    // Do any additional setup after loading the view.
}
- (void)creationView{

    UILabel *labelDay = [[UILabel alloc] initWithFrame:CGRectMake(17, 28, 60, 36)];
    
    [self.view addSubview:labelDay];
    labelDay.textColor = getColor(@"262626");
    labelDay.font = [UIFont systemFontOfSize:45];
    labelDay.text = @"23";
    
    UILabel *labelWeek = [[UILabel alloc] init];
    [self.view addSubview:labelWeek];
    [labelWeek mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(labelDay.mas_right).with.offset(5);
        make.height.offset(15);
        make.width.offset(70);
        make.top.equalTo(labelDay);
        
    }];
    labelWeek.text = @"星期五";
    labelWeek.textColor =getColor(@"262626");
    labelWeek.font = [UIFont systemFontOfSize:15];
    
    UILabel *labelYear = [[UILabel alloc] init];
    [self.view addSubview:labelYear];
    [labelYear mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(labelWeek.mas_bottom).with.offset(9);
        make.left.equalTo(labelDay.mas_right).with.offset(5);
        make.height.offset(15);
        make.width.offset(70);
        
    }];
    labelYear.text = @"07/2018";
    labelYear.textColor =getColor(@"262626");
    labelYear.font = [UIFont systemFontOfSize:15];
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    layout.itemSize = CGSizeMake((DEF_SCREEN_WIDTH - 40)/ 3, 110);
    
    downcollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, screenScale(130), DEF_SCREEN_WIDTH, 330 + 30) collectionViewLayout:layout];
    //
    [downcollectionView layoutIfNeeded];
    //    self.automaticallyAdjustsScrollViewInsets = NO;
    downcollectionView.pagingEnabled = NO;
    downcollectionView.delegate = self;
    downcollectionView.dataSource = self;
    
    
    [downcollectionView registerNib:[UINib nibWithNibName:@"ReleseCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"ReleseCollectionViewCell"];
    
    downcollectionView.showsHorizontalScrollIndicator = NO;
    downcollectionView.showsVerticalScrollIndicator = NO;
    
    
    //    self.collectionView.bounces = NO;
    downcollectionView.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:downcollectionView];


    
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}
//数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    
    return 7;
    
    
}
//内容

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    ReleseCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ReleseCollectionViewCell" forIndexPath:indexPath];
    NSArray *arrOfTitle = @[@"船舶交易", @"船员信息", @"货源信息", @"船舶档案", @"招聘求职", @"物流名录",@"船舶投诉"];
    cell.titleLabel.text = arrOfTitle[indexPath.row];
    NSArray *arrOfPic = @[@"fabu_icon_jiaoyi", @"fabu_icon_chuanyuan", @"fabu_icon_huoyuan", @"fabu_icon_dangan", @"fabu_icon_zhaopin", @"fabu_icon_minglu",@"fabu_icon_tousu"];
    cell.imgView.image = [UIImage imageNamed:arrOfPic[indexPath.row]];
    
    return cell;
    
    
    
}
//点击
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 3) {
        
        ReleaseRecordViewController * vc = [[ReleaseRecordViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (indexPath.row == 0){
  
  
          ReleaseDealViewController * vc = [[  ReleaseDealViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 2){
        
 
        ReleaseGoodsViewController * vc = [[ReleaseGoodsViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 5){
        
       
        ReleaseDirectoryViewController * vc = [[ReleaseDirectoryViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 6){
        

         ReleaseComplaintViewController * vc = [[ ReleaseComplaintViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 4){
        
       
         RealseApplyWorkViewController * vc = [[  RealseApplyWorkViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
